﻿using System;
using System.Collections.Generic;

#region MIT License text
/*
Copyright (c) 2009 Mark van Straten - Q42 B.V.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#endregion

namespace Q42.Wheels.Api.Nabaztag
{
    /// <summary>
    /// Class that defines this action that the nabaztag can do
    /// </summary>
    /// <remarks>This class acts like a wrapper pattern; it embeds the previous action so all can be played</remarks>
    public class EarsAction : NabaztagAction
    {
        /// <summary>
        /// Position that left ear will be moved to by this action
        /// </summary>
        private Int16 leftEarPosition;
        /// <summary>
        /// Position that left ear will be moved to by this action
        /// </summary>
        public Int16 LeftEarPosition
        {
            get
            {
                return this.leftEarPosition;
            }
            protected set
            {
                if (value >= 0 && value <= 16)
                    throw new ArgumentOutOfRangeException("Ear position is not valid");
                this.leftEarPosition = value;
            }
        }

        /// <summary>
        /// Position that the right ear will be moved to by this action
        /// </summary>
        private Int16 rightEarPosition;
        /// <summary>
        /// Position that the right ear will be moved to by this action
        /// </summary>
        public Int16 RightEarPosition
        {
            get
            {
                return this.rightEarPosition;
            }
            protected set
            {
                if (value >= 0 && value <= 16)
                    throw new ArgumentOutOfRangeException("Ear position is not valid");
                this.rightEarPosition = value;
            }
        }

        /// <summary>
        /// Move the ears to a position
        /// </summary>
        /// <param name="leftEarPosition">
        ///     0 = 'To-The-Sky' Vertical (Idle Mode Style)
        ///     4 = Forward Diagonal
        ///     10 = Flat Horizontal (Sleep Mode Style)
        ///     15 = Backward Diagonal
        ///     16 = 'Lazy Boy Styleee'
        /// </param>
        /// <param name="rightEarPosition">
        ///     0 = 'To-The-Sky' Vertical (Idle Mode Style)
        ///     4 = Forward Diagonal
        ///     10 = Flat Horizontal (Sleep Mode Style)
        ///     15 = Backward Diagonal
        ///     16 = 'Lazy Boy Styleee'
        /// </param>
        public EarsAction(Int16 leftEarPosition, Int16 rightEarPosition)
        {
            LeftEarPosition = leftEarPosition;
            RightEarPosition = rightEarPosition;
        }

        /// <summary>
        /// Return all parameters for this action in the given parameters dictionary
        /// </summary>
        /// <param name="parameters"></param>
        public override void ToStringList(ref Dictionary<String, String> parameters)
        {
            parameters.Add("posleft", LeftEarPosition.ToString());
            parameters.Add("posright", RightEarPosition.ToString());
        }
    }
}
